import { BaseWindow } from "../../../../../component/window/BaseWindow";
import { ILayer } from "../../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../../extend/language/Language";
import { ObjCreate } from "../../../common/ObjCreate";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { GuildRobCityCopyTwoResultRenderer } from "./GuildRobCityCopyTwoResultRenderer";
import { DataProvider } from "../../../../../../fl/data/DataProvider";
import { Cache } from "../../../../cache/Cache";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { SRobCityTwoJoinTeamInfo } from "../../../../../../Message/Public/SRobCityTwoJoinTeamInfo";
import { SRobCityTwoJoinTeam } from "../../../../../../Message/Public/SRobCityTwoJoinTeam";
import { GuildRobCityCopyTwoResultData } from "./GuildRobCityCopyTwoResultData";
import { GTileList } from "../../../../../../com/mui/controls/GTileList";
import { GButton } from "../../../../../../com/mui/controls/GButton";
//class GuildRobCityCopyTwoResult
    
    export  class GuildRobCityCopyTwoResult extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(305, 260);
            titleHeight = 25;
            title = Language.getString(60951);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 36, 269, 212, this);
            ObjCreate.createGTextField(Language.getString(70562), 30, 45, 45, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat5));
            ObjCreate.createGTextField(Language.getString(60944), 75, 45, 150, 20, this, GlobalStyle.textFormat5);
            ObjCreate.createGTextField(Language.getString(60945), 225, 45, 45, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat5));
            ObjCreate.createBg(20, 70, 230, 2, this, ImagesConst.SplitLine);
            this._listPanel = ObjCreate.createTileList(30, 75, 250, 140, this);
            this._listPanel.rowHeight = 22;
            this._listPanel.columnWidth = 245;
            this._listPanel.verticalScrollPolicy = "off";
            this._listPanel.setStyle("cellRenderer", GuildRobCityCopyTwoResultRenderer);
            this._listDp = new DataProvider();
            this._listPanel.dataProvider = this._listDp;
            this._leaveBtn = ObjCreate.createGButton(Language.getString(62039), 122, 213, 60, 26, this);
            this._leaveBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onLeaveBtnClick);
            return;
        }

        /* internal  */onLeaveBtnClick(arg1): void
        {
            if (Cache.instance.copy.isInCopy) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.CopyLeaveWithoutComfirm));
            }
            this.hide();
            return;
        }

        public setRankingData(arg1: SRobCityTwoJoinTeamInfo): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            this._listDp.removeAll();
            if (arg1.robCityTwoJoinTeams) 
            {
                arg1.robCityTwoJoinTeams.sortOn("score", Array.DESCENDING | Array.NUMERIC);
                loc3 = 0;
                while (loc3 < arg1.robCityTwoJoinTeams.length) 
                {
                    loc1 = arg1.robCityTwoJoinTeams[loc3] as SRobCityTwoJoinTeam;
                    loc2 = new GuildRobCityCopyTwoResultData();
                    loc2.rank = loc3 + 1;
                    loc2.score = loc1.score;
                    loc2.sEntityId = loc1.sEntityId;
                    loc2.guildName = loc1.guildName;
                    this._listDp.addItem(loc2);
                    ++loc3;
                }
            }
            this._listPanel.dataProvider = this._listDp;
            return;
        }

        /* internal */ /* var */_listPanel: GTileList;

        /* internal */ /* var */_listDp: DataProvider;

        /* internal */ /* var */_leaveBtn: GButton;
    }
